package com.example.intelligenttransportationteam1;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class LoginActivity extends AppCompatActivity {

    private EditText edtMainUser;
    private EditText edtMainPsw;
    private CheckBox cbMainRempsw;
    private CheckBox cbMainAutologin;
    private Button btnMainLogin;
    private Button btnMainRegister;
    private TextView tvMainSetting;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        initView();
        btnMainLogin.setOnClickListener(v -> {
            Intent intent = new Intent(LoginActivity.this, MainActivity.class);
            startActivity(intent);
        });

        btnMainRegister.setOnClickListener(v -> {
            Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
            startActivity(intent);
        });
    }

    private void initView() {
        edtMainUser = (EditText) findViewById(R.id.edt_main_user);
        edtMainPsw = (EditText) findViewById(R.id.edt_main_psw);
        cbMainRempsw = (CheckBox) findViewById(R.id.cb_main_rempsw);
        cbMainAutologin = (CheckBox) findViewById(R.id.cb_main_autologin);
        btnMainLogin = (Button) findViewById(R.id.btn_main_login);
        btnMainRegister = (Button) findViewById(R.id.btn_main_register);
        tvMainSetting = (TextView) findViewById(R.id.tv_main_setting);
    }

    public void Setting(View view) {
        netsettingDialog();
    }

    public void netsettingDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
        View view = LayoutInflater.from(LoginActivity.this).inflate(R.layout.activity_net_setting, null, false);
        builder.setView(view);
        Dialog dialog = builder.create();
        EditText edtIP = view.findViewById(R.id.edtNsdialogAdress);
        EditText edtPort = view.findViewById(R.id.edtNsdialogPws);
        Button btnSave = view.findViewById(R.id.btnNsdialogSave);
        Button btnCancel = view.findViewById(R.id.btnNsdialogCancle);
        btnSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        btnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        dialog.show();


    }

}